package com.security.auth.handler;

import org.apache.commons.lang3.StringUtils;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author yanggld
 * @Date 2020/3/12-15:55
 */
@Component
public class Oauth2LogoutSuccessHandler implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
        throws IOException, ServletException {
        String redirectUri = request.getParameter("redirect_uri");
        if (!StringUtils.isBlank(redirectUri)) {
            response.sendRedirect(redirectUri);
        }
    }
}
